package com.example.zzk;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MentAdapter extends RecyclerView.Adapter<MentAdapter.MentViewHolder> {
    public MentAdapter(List<Bean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    private List<Bean> data;
    private Context context;


    @NonNull
    @Override
    public MentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = View.inflate(context,R.layout.ment_item,null);
        return new MentViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MentViewHolder holder, int position) {
        holder.tv.setText(data.get(position).getName() + " ");

        holder.tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context,RoomActivity.class);
                context.startActivity(intent);

            }
        });

    }

    @Override
    public int getItemCount() {
        return data == null ? 0 : data.size();
    }

    public class MentViewHolder extends RecyclerView.ViewHolder {
        private TextView tv;
        public MentViewHolder(@NonNull View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.tv_name);

        }
    }
}
